/*
 * VentanaInvitarJugador.java
 *
 * Created on 25 de septiembre de 2008, 03:36 PM
 */
package GUI;

import Enlace.TramaNombre;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author  Propietario
 */
public class VentanaInvitarJugador extends javax.swing.JFrame {
    private List imagenes;
    private String po;
    private Vector <String> DatosNombre = new Vector<String>();
    private Vector <String> tramaNombre = new Vector<String>();
    private int j1;
    /** Creates new form VentanaInvitarJugador */
    public VentanaInvitarJugador(List imagen, String port) {
        initComponents();
        imagenes = new ArrayList(imagen);
        po = port; 
        this.setTitle("Invitar jugador");
        Random rm = new Random();
        j1 = rm.nextInt() % 2;
    }    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLInvitarJug = new javax.swing.JLabel();
        jLNombre = new javax.swing.JLabel();
        jBInvitar = new javax.swing.JButton();
        jTNomJugador = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));

        jLInvitarJug.setFont(new java.awt.Font("Arial", 1, 18));
        jLInvitarJug.setForeground(new java.awt.Color(255, 153, 0));
        jLInvitarJug.setText("INVITAR JUGADOR");

        jLNombre.setFont(new java.awt.Font("Arial", 1, 14));
        jLNombre.setForeground(new java.awt.Color(255, 153, 0));
        jLNombre.setText("Nombre");

        jBInvitar.setBackground(new java.awt.Color(0, 0, 0));
        jBInvitar.setFont(new java.awt.Font("Arial", 1, 12));
        jBInvitar.setForeground(new java.awt.Color(204, 102, 0));
        jBInvitar.setText("Invitar");
        jBInvitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBInvitarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(184, 184, 184)
                        .addComponent(jLInvitarJug))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(jLNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTNomJugador, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(206, 206, 206)
                        .addComponent(jBInvitar, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTNomJugador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLInvitarJug)
                        .addGap(81, 81, 81)))
                .addGap(31, 31, 31)
                .addComponent(jBInvitar)
                .addContainerGap(45, Short.MAX_VALUE))
        );

        jMenu1.setText("Archivo");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Acerca de...");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBInvitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBInvitarActionPerformed
        try {
            // TODO add your handling code here:
            String nombreJug = new String();
            nombreJug = jTNomJugador.getText();
            System.out.println(nombreJug);
            
            this.dispose();
            TramaNombre tn = new TramaNombre();
            DatosNombre = tn.armarDatosNombre(nombreJug);
            tramaNombre = tn.aramarTramasNombre(DatosNombre);
            
            PantallaJugador pan = new PantallaJugador(imagenes, po, tramaNombre, j1);
            pan.setVisible(true);
               
            //----------se debe enviar la trama con el nombre
        } catch (Exception ex) {
            Logger.getLogger(VentanaInvitarJugador.class.getName()).log(Level.SEVERE, null, ex);
        }
        //----------se debe enviar la trama con el nombre
}//GEN-LAST:event_jBInvitarActionPerformed
    /**
     * @param args the command line arguments
     */
      
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBInvitar;
    private javax.swing.JLabel jLInvitarJug;
    private javax.swing.JLabel jLNombre;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTNomJugador;
    // End of variables declaration//GEN-END:variables
    
    @Override
    protected void processWindowEvent(WindowEvent e) {
        //super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            //PPrincipal pantallaPrincipal = new PPrincipal();
            //pantallaPrincipal.setVisible(true);
            this.dispose();
            }
    }
}
